import cn.hutool.core.util.RandomUtil;
import com.bigmodel.util.FtlUtil;
import com.bigmodel.baidu.BaiduWenXin;
import cn.hutool.http.HttpUtil;
import org.junit.Test;

import java.util.HashMap;
import java.util.Map;

public class PromptApi {



    @Test
    public void test1() {
        String systemName= "CRM系统";
        String url = " http://localhost:8888/api/test/getDbStatus?name="+systemName;
        String result = HttpUtil.get(url);

        Map<String, Object> map = new HashMap<>();
        map.put("apiResponse",result);
        map.put("systemName",systemName);
        String questionContent = FtlUtil.generateContent(map, "api/getDbStatus.ftl");
        String answerContent = BaiduWenXin.chat(questionContent);
        System.out.println(answerContent);
    }


    @Test
    public void test2() {
        String systemName= "CRM系统";
        String url = " http://localhost:8888/api/test/restartDb?name="+systemName;
        String result = HttpUtil.get(url);

        Map<String, Object> map = new HashMap<>();
        map.put("apiResponse",result);
        map.put("systemName",systemName);
        String questionContent = FtlUtil.generateContent(map, "api/restartDb.ftl");
        String answerContent = BaiduWenXin.chat(questionContent);
        System.out.println(answerContent);
    }

    @Test
    public void test3() {
        String systemName= "CRM系统";
        String url = " http://localhost:8888/api/test/relationByName?name="+systemName;
        String result = HttpUtil.get(url);

        Map<String, Object> map = new HashMap<>();
        map.put("apiResponse",result);
        map.put("systemName",systemName);
        String questionContent = FtlUtil.generateContent(map, "api/relationByName.ftl");
        String answerContent = BaiduWenXin.chat(questionContent);
        System.out.println(answerContent);
    }

    @Test
    public void test4() {
        String instanceName= "adminCenter";
        String url = " http://localhost:8888/api/test/getInstanceStatus?name="+instanceName;
        String result = HttpUtil.get(url);

        Map<String, Object> map = new HashMap<>();
        map.put("apiResponse",result);
        map.put("instanceName",instanceName);
        String questionContent = FtlUtil.generateContent(map, "api/getInstanceStatus.ftl");
        String answerContent = BaiduWenXin.chat(questionContent);
        System.out.println(answerContent);
    }

    @Test
    public void test5() {
        String instanceName= "adminCenter";
        String url = " http://localhost:8888/api/test/restartInstance?name="+instanceName;
        String result = HttpUtil.get(url);

        Map<String, Object> map = new HashMap<>();
        map.put("apiResponse",result);
        map.put("instanceName","adminCenter");
        String questionContent = FtlUtil.generateContent(map, "api/restartInstance.ftl");
        String answerContent = BaiduWenXin.chat(questionContent);
        System.out.println(answerContent);
    }


    @Test
    public void test6(){

        for(int i = 0 ; i< 100;i++){
            System.out.println(RandomUtil.randomLong(0,2));
        }

    }






}
